define(function(require,exports,module){
    var Base={
		mBaserSvrUrl:window.BaseServerUrl,
		localStorage:window.localStorage
	};
	
	function JlnRequest(){
		this.params={}
	}
	module.exports=AccountProxy;
function AccountProxy(){
	function accountSubmit(request, success, ignoreError) {
	    var url = Base.mBaserSvrUrl+'/account';
        if (request.svr == null) request.svr = undefined;
	    if (request.token == null) request.token = undefined;
	    var content = JSON.stringify(request);
       
	    url = url + '?f=t&data=' + encodeURIComponent(content);
	    url = url + '&CallBack=?';
        $.getJSON(url,success);

	}

	function banksPayRq(union,userToken,orderFormSId,money,bankTypeCode,tradeType,success,ignoreError){
        var request=new JlnRequest();
        request.func='banksPay';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['ofsid']=orderFormSId;
		request.params['m']=money;
		request.params['btc']=bankTypeCode;
		request.params['tt']=tradeType;

		if (union == true) {
	        request.svr = 'account';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.banksPayRequest=function(userToken,orderFormSId,money,bankTypeCode,tradeType,success,ignoreError){
       var request= banksPayRq(true,userToken,orderFormSId,money,bankTypeCode,tradeType,success,ignoreError);
       return request;
    }
	this.banksPay=function(userToken,orderFormSId,money,bankTypeCode,tradeType,success,ignoreError){
       var request= banksPayRq(false,userToken,orderFormSId,money,bankTypeCode,tradeType,success,ignoreError);
       accountSubmit(request, success, ignoreError);

    }

	function isPaidRq(union,userToken,orderFormSId,success,ignoreError){
        var request=new JlnRequest();
        request.func='isPaid';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['ofsid']=orderFormSId;

		if (union == true) {
	        request.svr = 'account';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.isPaidRequest=function(userToken,orderFormSId,success,ignoreError){
       var request= isPaidRq(true,userToken,orderFormSId,success,ignoreError);
       return request;
    }
	this.isPaid=function(userToken,orderFormSId,success,ignoreError){
       var request= isPaidRq(false,userToken,orderFormSId,success,ignoreError);
       accountSubmit(request, success, ignoreError);

    }

	function paymentConfirmRq(union,userToken,orderFormSId,payTime,payer,payBankCardNo,payBankName,payChannelName,paymentUrl,remark,success,ignoreError){
        var request=new JlnRequest();
        request.func='paymentConfirm';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['userToken']=userToken;
		request.params['ofsid']=orderFormSId;
		request.params['pt']=payTime;
		request.params['p']=payer;
		request.params['pbcn']=payBankCardNo;
		request.params['pbn']=payBankName;
		request.params['pcn']=payChannelName;
		request.params['pu']=paymentUrl;
		request.params['r']=remark;

		if (union == true) {
	        request.svr = 'account';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.paymentConfirmRequest=function(userToken,orderFormSId,payTime,payer,payBankCardNo,payBankName,payChannelName,paymentUrl,remark,success,ignoreError){
       var request= paymentConfirmRq(true,userToken,orderFormSId,payTime,payer,payBankCardNo,payBankName,payChannelName,paymentUrl,remark,success,ignoreError);
       return request;
    }
	this.paymentConfirm=function(userToken,orderFormSId,payTime,payer,payBankCardNo,payBankName,payChannelName,paymentUrl,remark,success,ignoreError){
       var request= paymentConfirmRq(false,userToken,orderFormSId,payTime,payer,payBankCardNo,payBankName,payChannelName,paymentUrl,remark,success,ignoreError);
       accountSubmit(request, success, ignoreError);

    }

	function cancelTradeOrderRq(union,orderFormId,success,ignoreError){
        var request=new JlnRequest();
        request.func='cancelTradeOrder';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['ofid']=orderFormId;

		if (union == true) {
	        request.svr = 'account';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.cancelTradeOrderRequest=function(orderFormId,success,ignoreError){
       var request= cancelTradeOrderRq(true,orderFormId,success,ignoreError);
       return request;
    }
	this.cancelTradeOrder=function(orderFormId,success,ignoreError){
       var request= cancelTradeOrderRq(false,orderFormId,success,ignoreError);
       accountSubmit(request, success, ignoreError);

    }
}

});
